package com.myidis.mapper;

import com.myidis.entity.*;
import com.myidis.request.DICalculatorReq;
import com.myidis.request.SearchReq;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

public interface CIResultMapper {

    @Select("SELECT * FROM ciresultslist")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "subject", column = "subject"),
            @Result(property = "calTime", column = "calTime"),
            @Result(property = "combination", column = "combination"),
            @Result(property = "springDay", column = "springDay"),
            @Result(property = "calculator", column = "calculator"),
            @Result(property = "startTime", column = "startTime"),
            @Result(property = "endTime", column = "endTime")

    })
    ArrayList<IndexResultList> list();

    @Select("SELECT * FROM ciresults where listId = #{keyNum1}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "listId", column = "listId"),
            @Result(property = "time", column = "time"),
            @Result(property = "combination", column = "combination"),
            @Result(property = "LeadCI", column = "LeadCI"),
            @Result(property = "CoinCI", column = "CoinCI"),
            @Result(property = "LagCI", column = "LagCI"),
            @Result(property = "BenchmarkCI", column = "BenchmarkCI")
    })
    ArrayList<FullCIResult> getData(SearchReq sea);

    @Select("SELECT * FROM ciresultslist where id = #{id}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "subject", column = "subject"),
            @Result(property = "calTime", column = "calTime"),
            @Result(property = "combination", column = "combination"),
            @Result(property = "springDay", column = "springDay"),
            @Result(property = "calculator", column = "calculator"),
            @Result(property = "startTime", column = "startTime"),
            @Result(property = "endTime", column = "endTime")

    })
    IndexResultList getInfo(int sea);

    @Insert("INSERT intO ciresults(listId, time, leadCI, CoinCI, LagCI, BenchmarkCI) VALUES( #{subject}, #{time}, #{leadCI}, " +
            "#{CoinCI}, #{LagCI},#{BenchmarkCI})")
    int insertDetail(FullCIResult set);

    @Insert("INSERT intO ciresultslist(subject, springDay, calTime, combination, calculator, startTime, endTime) VALUES(" +
            " #{subject},#{springDay}, #{calTime}, #{combination}, #{calculator}, #{startTime}, #{endTime})")
    int insertList(IndexResultList set);

    @Delete("DELETE FROM ciresults WHERE listId = #{id}")
    int deleteData(int id);

    @Delete("DELETE FROM ciresultslist WHERE id = #{id}")
    int delete(int id);


}
